package com.fourhats.services.impl;

import java.util.ArrayList;
import java.util.List;

import org.dozer.Mapper;

public class FourhatsMapper <T, Dto>{
	
	public FourhatsMapper(Class<Dto> type, Mapper mapper) {
    	this.type = type; 
    	this.mapper = mapper;
    }
	
	private Class<Dto> type;
	
	private Mapper mapper;
	
	public List<Dto> map(List<T> ts, Mapper mapper){
		List<Dto> dtos = new ArrayList<Dto>();
		for(T t : ts) {
			dtos.add(mapper.map(t, this.type));
		}
		
		return dtos;
	}
	
	public Dto map(T t, Mapper mapper){
		return mapper.map(t, this.type);
	}
}
